<?php
class Upload extends Controller{
	public function uploadfile($file){
		//允许的文件类型
		$allowtype=array(".jpg",".png",".gif",".jpeg");
		//取得后缀
		$houzhui=strrchr($file['name'], ".");
		if (!in_array($houzhui,$allowtype)) {
			$this->jump("index.php?p=admin&c=brand&a=add", "不支持'{$houzhui}'后缀的图片!",3);
		}
		$newname=date('YmdHis').rand(1000, 2000);
		$newname.=$houzhui;
		
		if(move_uploaded_file($file['tmp_name'], UPLOAD_PATH.$newname)){
			return UPLOAD_PATH.$newname;
		}else {
			return false;
		}
		
	}
	
	public function deleteimg($img){
		unlink($img);
	}
	
	
}